{% extends 'base.html' %}
{% block css %}
<link href="/static/css/dataTables.bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="right_col" role="main">
    <div class="">
        <div class="clearfix"></div>

        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>Salt主机列表 </h2>
                        <ul class="nav navbar-right panel_toolbox">
                            <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                            </li>
                            <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="#">Settings 1</a>
                                </li>
                                <li><a href="#">Settings 2</a>
                                </li>
                            </ul>
                            </li>
                            <li><a class="close-link"><i class="fa fa-close"></i></a>
                            </li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                    <div class="info"><a href="{% url 'key_import' %}" class="btn btn-info btn-sm" role="button" {% if not perms.deploy.edit_salthost %}disabled="disabled"{% endif %} data-toggle="tooltip" data-placement="right" title="系统计划任务，如非必要，请勿执行此操作">刷新Salt主机列表</a></div>
                    <div class="x_content">
                        <div class="ln_solid"></div>
                        <div class="info">
                            <b>未授权Key</b><p></p></div>
                        <table id="datatable1" class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>主机</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for m in all_minions_pre %}
                                <tr>
                                    <td>{{ m.hostname }}</td>
                                    <td>{{ m.alive }}</td>
                                    <td>
                                        <a class="btn btn-info btn-sm" href="{% url 'key_add' %}?hostname={{ m.hostname }}&add=1" {% if not perms.deploy.edit_salthost %}disabled="disabled"{% endif %}><i class="fa fa-plus-square "></i></a>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>

                    <div class="x_content">
                        <div class="ln_solid"></div>
                        <div class="info">
                            <b>已授权Key</b><p></p></div>
                        <table id="datatable" class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>主机</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for m in all_minions %}
                                <tr>
                                    <td>{{ m.hostname }}</td>
                                    <td>{{ m.alive }}</td>
                                    <td>
                                        <a class="btn btn-info btn-sm" href="{% url 'key_flush' %}?hostname={{ m.hostname  }}&flush=1" {% if not perms.deploy.edit_salthost %}disabled="disabled"{% endif %}><i class="fa fa-refresh "></i></a>
                                        <a class="btn btn-danger btn-sm" href="{% url 'key_delete' %}?hostname={{ m.hostname }}&delete=1" {% if not perms.deploy.edit_salthost %}disabled="disabled"{% endif %}><i class="fa fa-trash-o "></i></a>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
{% block js %}
<script src="/static/js/jquery.dataTables.min.js"></script>
<script src="/static/js/dataTables.bootstrap.min.js"></script>
<!-- Datatables -->
<script>
    $(document).ready(function() {
            $('#datatable').dataTable();
            $('#datatable1').dataTable();
            });
</script>
<!-- /Datatables -->
{% endblock %}
